//统一管理咱们项目用户相关的接口
import request from "@/utils/request";
import {
    RoleAddOrUpdateForm,
    RoleAllListReponseData,
    RolePageListReponseData
} from "@/api/business/role/type";
import {HandleResponseData, UuidForm} from "@/api/common/type";


//项目用户相关的请求地址
enum API {
    //全部用户
    allRoleUrl = "/bg/role/allList",
    //某用户拥有权限
    userRoleListUrl = "/bg/role/userInfo",

    //分页列表
    pageListUrl = "/bg/role/pageList",
    //详情
    roleInfoUrl = "/bg/role/detail",
    //编辑
    updateRoleUrl = "/bg/role/update",
    //添加
    addRoleUrl = "/bg/role/add",
    //删除
    delRoleUrl = "/bg/role/batchDel"

}

//全部角色
export const reqAllRole = () => request.get<any, RoleAllListReponseData>(API.allRoleUrl);
//某用户拥有的角色
export const reqUserRole = (userUuid: string) => request.get<any, RoleAllListReponseData>(API.userRoleListUrl +`?userUuid=${userUuid}`);
//分页列表
export const reqPageListRole = (page: number, pageSize: number,roleNameLike: string) => request.get<any, RolePageListReponseData>(API.pageListUrl +`?roleNameLike=${roleNameLike}&page=${page}&pageSize=${pageSize}`);

export const reqRoleInfo = (uuid: string) => request.get<any, RolePageListReponseData>(API.roleInfoUrl +`?uuid=${uuid}`);

export const reqAddOrUpdateRole = (data: RoleAddOrUpdateForm) => {
    if (data.uuid) {
        return request.post<any, HandleResponseData>(API.updateRoleUrl, data);
    } else {
        return request.post<any, HandleResponseData>(API.addRoleUrl, data);
    }
}


export const reqDelRole = (uuidFrom: UuidForm) => request.post<any, HandleResponseData>(API.delRoleUrl,uuidFrom);

